using UnityEngine;
using System;

namespace TripleMatch
{
    public class SFXManager : MonoBehaviour
    {
        [SerializeField] AudioSource m_audioSource = null;

        public void Game(GameSound type)
        {
            var audio = GameDefine.S.GetAudioClip(type);
            if (audio == null) return;
            PlaySound(audio);
        }

        public void Stop()
        {
            if (m_audioSource.isPlaying)
            {
                m_audioSource.Stop();
            }
        }

        public void Pause()
        {
            m_audioSource.Pause();
        }

        public void Resume()
        {
            if (m_audioSource != null)
                m_audioSource.UnPause();
        }

        public void OnApplicationPause(bool pauseStatus)
        {
            if (pauseStatus)
            {
                Pause();
            }
            else
            {
                Resume();
            }
        }

        private void PlaySound(AudioClip audioClip)
        {
            if (DataManager.S.audioIsOpen)
            {
                m_audioSource.PlayOneShot(audioClip);
            }
        }
    }
}


   